package com.maxuxu.scihome.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @className: MailService
 * @author: Maxuxu
 * @date: 2022/7/6 13:18
 * @description:
 */
@Component
public class MailService {
    @Autowired
    JavaMailSender javaMailSender;

    public void sendMail(String from,String to,
                         String subject,String content){
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(from);
        simpleMailMessage.setTo(to);
        simpleMailMessage.setSubject(subject);
        simpleMailMessage.setText(content);
        javaMailSender.send(simpleMailMessage);
    }
}
